package models

import (
	"time"
)

// MessageStatus 消息状态枚举
type MessageStatus string

const (
	MessageStatusPending  MessageStatus = "pending"  // 待处理
	MessageStatusConsumed MessageStatus = "consumed" // 已消费
	MessageStatusFailed   MessageStatus = "failed"   // 失败
)

// MessageHistory 消息历史记录模型
type MessageHistory struct {
	ID           uint64        `gorm:"primaryKey;autoIncrement" json:"id"`
	Topic        string        `gorm:"type:varchar(255);not null;index" json:"topic"`
	MQType       MQType        `gorm:"type:varchar(50);not null;index" json:"mq_type"`
	Message      string        `gorm:"type:text;not null" json:"message"`
	Status       MessageStatus `gorm:"type:varchar(20);not null;index" json:"status"`
	ErrorMessage string        `gorm:"type:text" json:"error_message,omitempty"`
	Result       string        `gorm:"type:text" json:"result,omitempty"`
	CreatedAt    time.Time     `gorm:"index" json:"created_at"`
	ConsumedAt   *time.Time    `json:"consumed_at,omitempty"`
}

// TableName 指定表名
func (MessageHistory) TableName() string {
	return "message_history"
}
